package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(20);unique;not null;comment:用户名"`
	Password string `gorm:"type:char(32);not null;comment:密码"`
	State    int    `gorm:"type:tinyint(1);default:0;comment:状态:0-正常,1-冻结"`
	Image    string `gorm:"type:varchar(255);comment:头像"`
}

func (u *User) AddUser() error {
	return DB.Create(&u).Error
}
func (u *User) GetUser(state int) (user []*User, err error) {
	err = DB.Model(&User{}).Where("state = ?", state).Find(&user).Error
	return
}
